<?php

namespace IDock\Insurance\ZYIC\Response;

use IDock\Http\Response;
use IDock\IDock\IDockEnums;
use IDock\Insurance\ZYIC\ZYICEnums;
use IDock\Insurance\ZYIC\Response\AllZYICResponse;
use IDock\Printer\PolicyPaymentPrinter;
use IDock\Printer\preInquiryPrinter;
use IDock\Printer\ProposalStatusPrinter;
use IDock\Printer\VehicleModelPrinter;
use IDock\Printer\VehiclePrinter;

class PolicyInfoResponse extends AllZYICResponse
{

    /**
     * @var ProposalStatusPrinter $printer
     */
    public $printer = ProposalStatusPrinter::class;

    public function printerInit(): Response
    {
        $body = $this->getBody();
        $data = $body['content'] ?? [];
        $status = $data['underwriteFlag'] ?? '';

        $this->printer->policyNo = $data['policyNo'] ?? '';
        //下发
        if ($status == '2') {
            $this->printer->statusCode = 'U4';
        }
        //成功
        if (in_array($status,['4','5']))  {
            $this->printer->statusCode = 'U1';
        }
        //承保
        if($status == '1'){
            $this->printer->statusCode = 'U5';
        }
        //人工
        if ($status == '9') {
            $this->printer->statusCode = 'U3';
        }
        $this->printer->status = IDockEnums::$underStats[$this->printer->statusCode] ?? '';
        return $this;
    }
}
